<template>
  <div style="padding: 15px;">
    <Table border ref="selection" :columns="columns" :data="tableData"></Table>
    <Modal v-model="editRoleAuthority" :title="modalTitle" @on-ok="ok" @on-cancel="cancel">
      <Form :model="orgTeacherForm" :label-width="80">
        <FormItem label="角色名">
          <Input v-model="orgTeacherForm.name" vaule="" placeholder="请输入角色名"/>
        </FormItem>
        <FormItem label="权限">
          <Tree :data="authority" show-checkbox></Tree>
        </FormItem>
      </Form>
    </Modal>
  </div>
</template>

<script>
export default {
  name: 'index',
  data () {
    return {
      orgTeacherForm: {},
      orgAdmin: '',
      orgAdminList: [
        {
          userName: 'zhumo',
          realName: '朱墨'
        },
        {
          userName: 'caimingxu',
          realName: '蔡明旭'
        }
      ],
      columns: [
        {
          type: 'selection',
          width: 60,
          align: 'center'
        },
        {
          title: '角色名',
          key: 'name',
          align: 'center'
        },
        {
          title: '角色权限',
          key: 'userName',
          align: 'center'
        },
        {
          title: '修改时间',
          key: 'createTime',
          align: 'center',
          width: 150
        },
        {
          title: '修改人',
          key: 'operator',
          align: 'center'
        },
        {
          title: '操作',
          key: 'action',
          width: 150,
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h('Button', {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                style: {
                  marginRight: '5px'
                },
                on: {
                  click: () => {
                    this.editRoleAuthority = true
                    this.modalTitle = '编辑角色'
                  }
                }
              }, '编辑')
            ])
          }
        }
      ],
      tableData: [
        {
          name: '朱自清',
          orgBelong: '杭州钱塘外国语学校',
          userName: 'zhuziqing',
          phone: '13578869443',
          famousTeacher: '1',
          createTime: '2018-11-15 12:10:11',
          updateTime: '2018-11-15 12:10:11',
          operator: 'admin',
          status: '1'
        },
        {
          name: '袁世凯',
          orgBelong: '北平家里蹲大学',
          userName: 'littleyuan',
          phone: '13102189443',
          famousTeacher: '0',
          createTime: '2018-11-15 12:10:11',
          updateTime: '2018-11-15 12:10:11',
          operator: 'admin',
          status: '0'
        }
      ],
      cityList: [
        {
          value: 'Zhe Jiang',
          label: '浙江省'
        },
        {
          value: 'An Hui',
          label: '安徽省'
        },
        {
          value: 'Shanghai',
          label: '上海市'
        },
        {
          value: 'Beijing',
          label: '北京市'
        },
        {
          value: 'He Bei',
          label: '河北省'
        },
        {
          value: 'Jiang Su',
          label: '江苏省'
        }
      ],
      areaModel: '',
      editRoleAuthority: false,
      modalTitle: '',
      authority: [
        {
          title: 'parent 1',
          expand: true,
          children: [
            {
              title: 'parent 1-1',
              expand: true,
              children: [
                {
                  title: 'leaf 1-1-1'
                },
                {
                  title: 'leaf 1-1-2'
                }
              ]
            },
            {
              title: 'parent 1-2',
              expand: true,
              children: [
                {
                  title: 'leaf 1-2-1'
                },
                {
                  title: 'leaf 1-2-1'
                }
              ]
            }
          ]
        }
      ]
    }
  },
  methods: {
    addOrg () {
      this.orgTeacherModal = true
      this.modalTitle = '添加教师'
    },
    searchOrg () {
    }
  }
}
</script>

<style scoped>

</style>
